<template>
	<view class="exApplyList">
		<view style="padding: 0 32rpx;" v-if="dataList.length">
			<view class="list" v-for="item in dataList" :key="item.id">
				<view class="content" @click="fillIn(item.id)">
					<text class="c_title">{{ item.title }}</text>
					<text class="c_cont">{{ item.gmtCreate }}</text>
				</view>
				<view class="getBtn">
					<van-button class="button" round type="primary" @click="receive(item)">报名</van-button>
				</view>
			</view>
		</view>
		<view v-else class="noData">
			<view class="text">暂无鉴定工告列表</view>
		</view>
		 <view class="loading" v-show="isShowMore">没有更多数据了~</view>
	</view>
</template>

<script>
	import { meetingList } from '@/api/home'
	export default {
		data() {
			return {
				pagination: {
					pageSize: 10,
					pageNum: 1
				},
				total: 0,
				dataList: [],
			}
		},
		onPullDownRefresh() {
			this.pagination.pageNum = 1;
			setTimeout(() => {
				this.getList();
			}, 200)
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1300);
		},
		onReachBottom() {
			console.log('onReachBottom')
			if ((this.pagination.pageSize * this.pagination.pageNum) >= this.total) {
				return
			}
			this.pagination.pageNum++;
			this.getList('more')
		},
		computed: {
			isShowMore() {
				if ((this.pagination.pageSize * this.pagination.pageNum) >= this.total && this.dataList.length) {
					return true
				} else {
					return false
				}
			}
		},
		mounted() {
			this.getList()
		},
		methods: {
			getList(mode) {
				meetingList(this.pagination).then(res => {
					if (mode == 'more') {
						this.dataList = this.dataList.concat(res.data.rows);
					} else {
						this.dataList = res.data.rows;
					}
					this.total = res.data.total;
				})
			},
			receive(data) {
				uni.navigateTo({
					url:`/packageA/pages/applyList/index?id=${data.id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.exApplyList {
		width: 100%;
		position: relative;
		background: #f5f5f5;
		min-height: 100vh;
		padding-top: 1rpx;
		.list {
			padding: 24rpx 16rpx;
			box-sizing: border-box;
			background-color: #FFFFFF;
			border-radius: 16rpx;
			margin-top: 20px;
			position: relative;
			.content {
				display: flex;
				flex-direction: column;
				.c_title {
					color: #333333;
					font-size: 32rpx;
				}
				.c_cont {
					color: #666666;
					font-size: 28rpx;
					margin-top: 16rpx;
				}
			}
			.getBtn {
				width: 100rpx;
				position: relative;
				position: absolute;
				bottom: 24rpx;
				right: 16rpx;
				.button {
					width: 104rpx;
					height: 48rpx;
					font-size: 24rpx;
					/deep/ .van-button--normal {
						color: #FFFFFF;
						width: 100%;
						height: 100%;
						padding: 0 0;
						font-size: 24rpx;
						font-weight: 200;
					}
				}
			}
			.appraising {
				position: absolute;
				right: 0;
				top: 0;
				width: 130rpx;
				height: 40rpx;
				background-color: #FBA517;
				line-height: 40rpx;
				text-align: center;
				border-radius: 0rpx 20rpx 0 20rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				&.besidesColor {
					background-color: #02BF88;
				}
			}
		}
	}
</style>
